public class Test01 {
    public ListNode swapPairs(ListNode head) {
        if(head == null || head.next == null) return head;
        ListNode dummy = new ListNode();
        dummy.next = head;
        ListNode prev = dummy;
        ListNode cur = head;
        ListNode curNext = cur.next; ListNode curNNext = curNext.next;
        while(cur != null && curNext != null){
            prev.next = curNext;
            curNext.next = cur;
            cur.next = curNNext;
            prev = cur;
            cur = curNNext;
            if(cur != null) curNext = cur.next;
            if(curNext != null) curNNext = curNext.next;
        }
        return dummy.next;
    }
}
